package com.attendance.www.hr.service.impl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.attendance.www.hr.beans.AttendanceBean;
import com.attendance.www.hr.beans.RestVacationBean;
import com.attendance.www.hr.dao.mapper.AttendanceExtMapper;
import com.attendance.www.hr.dao.mapper.DictionaryMapper;
import com.attendance.www.hr.dao.mapper.EmployeeMapper;
import com.attendance.www.hr.dao.mapper.FurloughBalanceMapper;
import com.attendance.www.hr.dao.mapper.FurloughExtMapper;
import com.attendance.www.hr.dao.mapper.FurloughMapper;
import com.attendance.www.hr.dao.mapper.LactationExtMapper;
import com.attendance.www.hr.dao.mapper.RequestAuthorityExtMapper;
import com.attendance.www.hr.dao.mapper.RequestAuthorityMapper;
import com.attendance.www.hr.dao.mapper.RequestExtMapper;
import com.attendance.www.hr.dao.mapper.RequestMapper;
import com.attendance.www.hr.dao.mapper.RestVacationExtMapper;
import com.attendance.www.hr.dao.mapper.SystemConfigureMapper;
import com.attendance.www.hr.entitys.Dictionary;
import com.attendance.www.hr.entitys.DictionaryExample;
import com.attendance.www.hr.entitys.Employee;
import com.attendance.www.hr.entitys.FurloughBalance;
import com.attendance.www.hr.entitys.FurloughBalanceExample;
import com.attendance.www.hr.entitys.Request;
import com.attendance.www.hr.entitys.RequestAuthority;
import com.attendance.www.hr.entitys.RequestAuthorityExample;
import com.attendance.www.hr.entitys.RequestExample;
import com.attendance.www.hr.entitys.SystemConfigure;
import com.attendance.www.hr.entitys.SystemConfigureExample;
import com.attendance.www.hr.service.IRestVacationService;
import com.attendance.www.hr.utils.YearFurloughUtils;

@Service
public class RestVacationServiceImpl implements IRestVacationService {
	@Resource
	private RequestAuthorityExtMapper requestAuthorityExtDao;
	@Resource
	private RequestAuthorityMapper requestAuthorityDao;
	@Resource
	private RequestExtMapper requestExtDao;
	@Resource
	private RequestMapper requestDao;
	@Resource
	private FurloughBalanceMapper furloughBalanceDao;
	@Resource
	private FurloughExtMapper furloughExtDao;
	@Resource
	private FurloughMapper furloughDao;
	@Resource
	private EmployeeMapper employeeDao;
	@Resource
	private RestVacationExtMapper restVacationExtDao;
	@Resource
	private LactationExtMapper lactationExtDao;
	@Resource
	private SystemConfigureMapper systemConfigureDao;
	@Resource
	private DictionaryMapper dictionaryDao;
	@Resource
	private AttendanceExtMapper attendanceDao;

	/**
	 * 查询假期额度信息
	 */
	@Override
	public List<RestVacationBean> getRestVacationList(RestVacationBean vacationBean) {
		//取年份
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
        int year = calendar.get(Calendar.YEAR);
        
		Integer employeeId=vacationBean.getEmployeeId();
		List<RestVacationBean> restVacationBeanList = new ArrayList<RestVacationBean>();
		{
			/*
			 * 年假
			 */
			//在申请中的年假时长 
			BigDecimal usingYearFurlough=new BigDecimal(0);
			RequestExample requestExample=new RequestExample();
			requestExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(1)
			.andReportYearEqualTo(year)
			.andApprovalStateEqualTo(1);
			List<Request> rList=requestDao.selectByExample(requestExample);
			if (rList.size()>0) {
				for (Request request : rList) {
					usingYearFurlough=usingYearFurlough.add(request.getHours());
				}
			}
			
			RestVacationBean restVacationBean = new RestVacationBean();
			restVacationBean.setFurloughType(1);
			DictionaryExample dictionaryExample = new DictionaryExample();
			dictionaryExample.createCriteria().andDicClsEqualTo("4").andDicCdEqualTo("1");
			Dictionary dictionary = dictionaryDao.selectByExample(dictionaryExample).get(0);
			restVacationBean.setRequstTypeName(dictionary.getDicName());
			
			//查询某人的当年年假（分钟数）
			Employee employee = employeeDao.selectByPrimaryKey(employeeId);
			Float yearFurloughFloat = YearFurloughUtils.getYearFurloughHours(employee.getFirstDate(), employee.getEntryDate(), new Date(), systemConfigureDao.selectByExample(new SystemConfigureExample())) * 480f;
			yearFurloughFloat=(float) Math.round(yearFurloughFloat);
			BigDecimal yearFurlough = null;
			
			//年假
			FurloughBalanceExample furloughBalanceExample=new FurloughBalanceExample();
			furloughBalanceExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andFurloughBalanceTypeEqualTo(1)
			.andYearEqualTo(Integer.toString(year));
			List<FurloughBalance> fList=furloughBalanceDao.selectByExample(furloughBalanceExample);
			yearFurlough = new BigDecimal(yearFurloughFloat.toString());
			if (fList.size()==0) {//余额表没有数据时
				restVacationBean.setUsedVacation(usingYearFurlough);
				restVacationBean.setRestVacation(yearFurlough.subtract(usingYearFurlough));
				restVacationBean.setTotalVacation(yearFurlough);
				restVacationBeanList.add(restVacationBean);
			} else {
				BigDecimal restYearFurlough=fList.get(0).getBalanceHoursDay();
				restVacationBean.setUsedVacation(yearFurlough.subtract((restYearFurlough).subtract(usingYearFurlough)));
				restVacationBean.setRestVacation(restYearFurlough.subtract(usingYearFurlough));
				restVacationBean.setTotalVacation(yearFurlough);
				restVacationBeanList.add(restVacationBean);
			}
		}
		
		{
			/*
			 * 调休
			 */
			RestVacationBean restVacationBean = new RestVacationBean();
			restVacationBean.setFurloughType(0);
			DictionaryExample dictionaryExample = new DictionaryExample();
			dictionaryExample.createCriteria().andDicClsEqualTo("4").andDicCdEqualTo("0");
			Dictionary dictionary = dictionaryDao.selectByExample(dictionaryExample).get(0);
			restVacationBean.setRequstTypeName(dictionary.getDicName());
			
			//加班总分钟数
			AttendanceBean attendanceBean=new AttendanceBean();
			attendanceBean.setEmployeeId(employeeId);
			Integer oveHoursInt=attendanceDao.getOvertime(attendanceBean);
			BigDecimal oveHours=new BigDecimal(0);
			if (oveHoursInt != null) {
				oveHours=new BigDecimal(oveHoursInt.toString());
			}
			
			//在申请中的调休时长
			BigDecimal usingOffHours=new BigDecimal(0);
			RequestExample requestExample=new RequestExample();
			requestExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(0)
			.andApprovalStateEqualTo(1);
			List<Request> rList=requestDao.selectByExample(requestExample);
			if (rList.size()>0) {
				for (Request request : rList) {
					usingOffHours=usingOffHours.add(request.getHours());
				}
			}
			
			//调休余额
			FurloughBalanceExample furloughBalanceExample=new FurloughBalanceExample();
			furloughBalanceExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andFurloughBalanceTypeEqualTo(0);
			List<FurloughBalance> fList=furloughBalanceDao.selectByExample(furloughBalanceExample);
			if (fList.size()>0) {
				//调休剩余时长分钟
				BigDecimal offHours=fList.get(0).getBalanceHoursDay();
				BigDecimal initHours=fList.get(0).getInitHoursDay();
				if (initHours==null) {
					initHours=new BigDecimal(0);
				}
				BigDecimal total=oveHours.add(initHours);
				restVacationBean.setUsedVacation(total.subtract(offHours.subtract(usingOffHours)));
				restVacationBean.setRestVacation(offHours.subtract(usingOffHours));
				restVacationBean.setTotalVacation(total);
				restVacationBeanList.add(restVacationBean);
			} else {
				restVacationBean.setUsedVacation(new BigDecimal(0));
				restVacationBean.setRestVacation(new BigDecimal(0));
				restVacationBean.setTotalVacation(new BigDecimal(0));
				restVacationBeanList.add(restVacationBean);
			}
		}
		
		{
			/*
			 * 产假
			 */
			RestVacationBean restVacationBean = new RestVacationBean();
			restVacationBean.setFurloughType(13);
			DictionaryExample dictionaryExample = new DictionaryExample();
			dictionaryExample.createCriteria().andDicClsEqualTo("4").andDicCdEqualTo("13");
			Dictionary dictionary = dictionaryDao.selectByExample(dictionaryExample).get(0);
			restVacationBean.setRequstTypeName(dictionary.getDicName());
			
			//在申请中的产假时长，或审批通过但还没有结束的产假
			RequestExample requestExample=new RequestExample();
			requestExample.or().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(13)
			.andApprovalStateEqualTo(1);
			requestExample.or().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(13)
			.andApprovalStateEqualTo(2)
			.andEndDateGreaterThanOrEqualTo(new Date());
			
			List<Request> rUsingList=requestDao.selectByExample(requestExample);
			
			//HR分配的产假权限表
			RequestAuthorityExample requestAuthorityExample=new RequestAuthorityExample();
			requestAuthorityExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(13);
			List<RequestAuthority> raList=requestAuthorityDao.selectByExample(requestAuthorityExample);
			
			//如果有正常申请的产假
			if (rUsingList.size()>0) {
				restVacationBean.setRestVacation(new BigDecimal(0));
				if (raList.size()>0) {
					//产假天数
					Integer maternityHours=raList.get(0).getHolidayQuota();
					Integer requestHours=rUsingList.get(0).getDayNumber();
					restVacationBean.setUsedVacation(new BigDecimal(requestHours.toString()));
					restVacationBean.setTotalVacation(new BigDecimal(maternityHours.toString()));
					restVacationBeanList.add(restVacationBean);
				}
			} else {
				if (raList.size()>0) {
					//产假天数
					Integer maternityHours=raList.get(0).getHolidayQuota();
					restVacationBean.setUsedVacation(new BigDecimal(0));
					restVacationBean.setRestVacation(new BigDecimal(maternityHours.toString()));
					restVacationBean.setTotalVacation(new BigDecimal(maternityHours.toString()));
					restVacationBeanList.add(restVacationBean);
				}
			}
		}
		return restVacationBeanList;
	}

	/**
	 * 根据类型查询假期额度信息 update by--zx 
	 */
	@Override
	public RestVacationBean getRestVacationByType(RestVacationBean restVacationBeans, Integer employeeId) {
		
		Integer furloughType=restVacationBeans.getFurloughType();
		SystemConfigure systemConfigure = systemConfigureDao.selectByExample(new SystemConfigureExample()).get(0);
		
		//调休0，年假1，产假13，
		RestVacationBean restVacationBean = new RestVacationBean();
		if (furloughType==0) {//调休0
			/**
			 * 调休
			 */
			restVacationBean.setFurloughType(0);
			//加班总分钟数
			AttendanceBean attendanceBean=new AttendanceBean();
			attendanceBean.setEmployeeId(employeeId);
			Integer oveHoursInt=attendanceDao.getOvertime(attendanceBean);
			BigDecimal oveHours=new BigDecimal(0);
			if (oveHoursInt != null) {
				oveHours=new BigDecimal(oveHoursInt.toString());
			}
			//在申请中的调休时长
			BigDecimal usingOffHours=new BigDecimal(0);
			RequestExample requestExample=new RequestExample();
			requestExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(0)
			.andApprovalStateEqualTo(1);
			List<Request> rList=requestDao.selectByExample(requestExample);
			if (rList.size()>0) {
				for (Request request : rList) {
					usingOffHours=usingOffHours.add(request.getHours());
				}
			}
			//调休余额
			FurloughBalanceExample furloughBalanceExample=new FurloughBalanceExample();
			furloughBalanceExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andFurloughBalanceTypeEqualTo(0);
			List<FurloughBalance> fList=furloughBalanceDao.selectByExample(furloughBalanceExample);
			if (fList.size()>0) {
				//调休剩余时长分钟
				BigDecimal offHours=fList.get(0).getBalanceHoursDay();
				BigDecimal initHours=fList.get(0).getInitHoursDay();
				if (initHours==null) {
					initHours=new BigDecimal(0);
				}
				BigDecimal total=oveHours.add(initHours);
				restVacationBean.setUsedVacation(total.subtract(offHours.subtract(usingOffHours)));
				restVacationBean.setRestVacation(offHours.subtract(usingOffHours));
				restVacationBean.setTotalVacation(total);
				restVacationBean.setRealRestVacation(offHours);
			} else {
				restVacationBean.setUsedVacation(new BigDecimal(0));
				restVacationBean.setRestVacation(new BigDecimal(0));
				restVacationBean.setTotalVacation(new BigDecimal(0));
				restVacationBean.setRealRestVacation(new BigDecimal(0));
			}
		} else if(furloughType==1){//年假1
			//取年份
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(restVacationBeans.getStartDate());
	        int year = calendar.get(Calendar.YEAR);
	        
			/*
			 * 年假
			 */
			restVacationBean.setFurloughType(1);
			
			//查询某人的当年年假（分钟数）
			Employee employee = employeeDao.selectByPrimaryKey(employeeId);
			Float yearFurloughFloat = YearFurloughUtils.getYearFurloughHours(employee.getFirstDate(), employee.getEntryDate(), restVacationBeans.getStartDate(),
					systemConfigureDao.selectByExample(new SystemConfigureExample())) * 8 * 60;
			yearFurloughFloat=(float) Math.round(yearFurloughFloat);
			BigDecimal yearFurlough = null;
			
			//年假
			FurloughBalanceExample furloughBalanceExample=new FurloughBalanceExample();
			furloughBalanceExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andFurloughBalanceTypeEqualTo(1)
			.andYearEqualTo(Integer.toString(year));
			List<FurloughBalance> fList=furloughBalanceDao.selectByExample(furloughBalanceExample);
			yearFurlough = new BigDecimal(yearFurloughFloat.toString());
			
			//在申请中的年假时长
			BigDecimal usingYearFurlough=new BigDecimal(0);
			RequestExample requestExample=new RequestExample();
			requestExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(1)
			.andReportYearEqualTo(year)
			.andApprovalStateEqualTo(1);
			List<Request> rList=requestDao.selectByExample(requestExample);
			if (rList.size()>0) {
				for (Request request : rList) {
					usingYearFurlough=usingYearFurlough.add(request.getHours());
				}
			}
			
			if (fList.size()==0) {//余额表没有数据时
				restVacationBean.setUsedVacation(usingYearFurlough);
				restVacationBean.setRestVacation(yearFurlough.subtract(usingYearFurlough));
				restVacationBean.setTotalVacation(yearFurlough);
				restVacationBean.setRealRestVacation(yearFurlough);
			} else {
				BigDecimal restYearFurlough=fList.get(0).getBalanceHoursDay();
				restVacationBean.setUsedVacation(yearFurlough.subtract((restYearFurlough).subtract(usingYearFurlough)));
				restVacationBean.setRestVacation(restYearFurlough.subtract(usingYearFurlough));
				restVacationBean.setTotalVacation(yearFurlough);
				restVacationBean.setRealRestVacation(restYearFurlough);
			}
		} else if(furloughType==13){//产假13
			/**
			 * 产假
			 */
			restVacationBean.setFurloughType(13);
			//在申请中的产假时长，或审批通过但还没有结束的产假
			RequestExample requestExample=new RequestExample();
			requestExample.or().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(13)
			.andApprovalStateEqualTo(1);
			requestExample.or().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(13)
			.andApprovalStateEqualTo(2)
			.andEndDateGreaterThanOrEqualTo(new Date());
			
			List<Request> rUsingList=requestDao.selectByExample(requestExample);
			
			//HR分配的产假权限表
			RequestAuthorityExample requestAuthorityExample=new RequestAuthorityExample();
			requestAuthorityExample.createCriteria().andEmployeeIdEqualTo(employeeId)
			.andRequestTypeEqualTo(13);
			List<RequestAuthority> raList=requestAuthorityDao.selectByExample(requestAuthorityExample);
			
			//如果有正常申请的产假
			if (rUsingList.size()>0) {
				restVacationBean.setRestVacation(new BigDecimal(0));
				if (raList.size()>0) {
					//产假天数
					Integer maternityHours=raList.get(0).getHolidayQuota();
					Integer requestHours=rUsingList.get(0).getDayNumber();
					restVacationBean.setUsedVacation(new BigDecimal(requestHours.toString()));
					restVacationBean.setTotalVacation(new BigDecimal(maternityHours.toString()));
				}
			} else {
				if (raList.size()>0) {
					//产假天数
					Integer maternityHours=raList.get(0).getHolidayQuota();
					restVacationBean.setUsedVacation(new BigDecimal(0));
					restVacationBean.setRestVacation(new BigDecimal(maternityHours.toString()));
					restVacationBean.setTotalVacation(new BigDecimal(maternityHours.toString()));
				}
			}
		} else if (furloughType == 3 || furloughType == 4 || furloughType == 5  || furloughType == 6) {
			//婚丧事病假
			restVacationBean.setTotalVacation(new BigDecimal(0));
		} else if (furloughType == 11) {//陪护假
			Integer regionType = employeeDao.selectByPrimaryKey(employeeId).getRegionType();
			if (regionType == 1) {
				restVacationBean.setRestVacation(new BigDecimal(systemConfigure.getEscortLeaveDalian().toString()));
			} else if (regionType == 2) {
				restVacationBean.setRestVacation(new BigDecimal(systemConfigure.getEscortLeaveBeijing().toString()));
			} else if (regionType == 3) {
				restVacationBean.setRestVacation(new BigDecimal(systemConfigure.getEscortLeaveShanghai().toString()));
			} else if (regionType == 4) {
				restVacationBean.setRestVacation(new BigDecimal(systemConfigure.getEscortLeaveDalian().toString()));
			}
			restVacationBean.setUsedVacation(new BigDecimal(0));
			restVacationBean.setFurloughType(11);
		} else if(furloughType == 12) {//产检假，写个假的8小时
			restVacationBean.setTotalVacation(new BigDecimal(8));
		}
		return restVacationBean;
	}

	/**
	 * 在1,2月份查询去年和今年的年假余额
	 */
	@Override
	public RestVacationBean getLastYearYearFurlough(RestVacationBean restVacationBean, Integer employeeId) {
		
		RestVacationBean newRestVacationBean=new RestVacationBean();
		//取年份
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(restVacationBean.getStartDate());
		int year = calendar.get(Calendar.YEAR);
		int lastYear = year - 1;
		newRestVacationBean.setThisYear(year);
		newRestVacationBean.setLastYear(lastYear);
		//年初、年末时间
		Calendar calendarBegin = Calendar.getInstance();
		calendarBegin.setTime(restVacationBean.getStartDate());
		calendarBegin.set(Calendar.MONTH, 0);
		calendarBegin.set(Calendar.DAY_OF_MONTH,1);
		calendarBegin.set(Calendar.HOUR_OF_DAY,0);
		calendarBegin.set(Calendar.MINUTE,0);
		calendarBegin.set(Calendar.SECOND,0);
		calendarBegin.set(Calendar.MILLISECOND,0);
		Date beginDate=calendarBegin.getTime();
		//去年的开始时间、结束时间
		Calendar lastCalendarBegin = Calendar.getInstance();
		lastCalendarBegin.setTime(beginDate);
		lastCalendarBegin.add(Calendar.YEAR, -1);
		Date lastBeginDate=lastCalendarBegin.getTime();
		
		/*
		 * 年假
		 */
		newRestVacationBean.setFurloughType(1);
		//系统配置表
		List<SystemConfigure>  scList=systemConfigureDao.selectByExample(new SystemConfigureExample());
		
		//查询某人的当年年假（分钟数）
		Employee employee = employeeDao.selectByPrimaryKey(employeeId);
		Float yearFurloughFloat = YearFurloughUtils.getYearFurloughHours(employee.getFirstDate(), employee.getEntryDate(), restVacationBean.getStartDate(), scList) * 8 * 60;
		yearFurloughFloat=(float) Math.round(yearFurloughFloat);
		//去年年假，分钟数
		Float lastYearFurloughFloat = YearFurloughUtils.getYearFurloughHours(employee.getFirstDate(), employee.getEntryDate(), lastBeginDate, scList) * 8 * 60;
		lastYearFurloughFloat=(float) Math.round(lastYearFurloughFloat);
		
		BigDecimal yearFurlough = null;
		BigDecimal lastYearFurlough = null;
		
		//年假
		FurloughBalanceExample furloughBalanceExample=new FurloughBalanceExample();
		furloughBalanceExample.createCriteria().andEmployeeIdEqualTo(employeeId)
		.andFurloughBalanceTypeEqualTo(1)
		.andYearEqualTo(Integer.toString(year));
		List<FurloughBalance> fList=furloughBalanceDao.selectByExample(furloughBalanceExample);
		
		FurloughBalanceExample furloughBalanceExample2=new FurloughBalanceExample();
		furloughBalanceExample2.createCriteria().andEmployeeIdEqualTo(employeeId)
		.andFurloughBalanceTypeEqualTo(1)
		.andYearEqualTo(Integer.toString(lastYear));
		List<FurloughBalance> lastFList=furloughBalanceDao.selectByExample(furloughBalanceExample2);
		
		yearFurlough = new BigDecimal(yearFurloughFloat.toString());
		lastYearFurlough = new BigDecimal(lastYearFurloughFloat.toString());
		
		//在申请中的年假时长
		BigDecimal usingYearFurlough=new BigDecimal(0);
		RequestExample requestExample=new RequestExample();
		requestExample.createCriteria().andEmployeeIdEqualTo(employeeId)
		.andRequestTypeEqualTo(1)
		.andReportYearEqualTo(year)
		.andApprovalStateEqualTo(1);
		List<Request> rList=requestDao.selectByExample(requestExample);
		if (rList.size()>0) {
			for (Request request : rList) {
				usingYearFurlough=usingYearFurlough.add(request.getHours());
			}
		}
		//在申请中的去年年假时长
		BigDecimal usingLastYearFurlough=new BigDecimal(0);
		RequestExample requestExample2=new RequestExample();
		requestExample2.createCriteria().andEmployeeIdEqualTo(employeeId)
		.andRequestTypeEqualTo(1)
		.andReportYearEqualTo(lastYear)
		.andApprovalStateEqualTo(1);
		List<Request> rLastList=requestDao.selectByExample(requestExample2);
		if (rLastList.size()>0) {
			for (Request request : rLastList) {
				usingLastYearFurlough=usingLastYearFurlough.add(request.getHours());
			}
		}
		
		if (fList.size()==0) {//余额表没有数据时
			newRestVacationBean.setUsedVacation(usingYearFurlough);
			newRestVacationBean.setRestVacation(yearFurlough.subtract(usingYearFurlough));
			newRestVacationBean.setTotalVacation(yearFurlough);
			newRestVacationBean.setRealRestVacation(yearFurlough);
		} else {
			BigDecimal restYearFurlough=fList.get(0).getBalanceHoursDay();
			newRestVacationBean.setUsedVacation(yearFurlough.subtract((restYearFurlough).subtract(usingYearFurlough)));
			newRestVacationBean.setRestVacation(restYearFurlough.subtract(usingYearFurlough));
			newRestVacationBean.setTotalVacation(yearFurlough);
			newRestVacationBean.setRealRestVacation(restYearFurlough);
		}
		//去年的年假
		if (lastFList.size()==0) {//余额表没有数据时
			newRestVacationBean.setLastYearUsedVacation(usingLastYearFurlough);
			newRestVacationBean.setLastYearRestVacation(lastYearFurlough.subtract(usingLastYearFurlough));
			newRestVacationBean.setLastYearTotalVacation(lastYearFurlough);
			newRestVacationBean.setRealLastYearRestVacation(lastYearFurlough);
			
		} else {
			BigDecimal restLastYearFurlough=lastFList.get(0).getBalanceHoursDay();
			newRestVacationBean.setLastYearUsedVacation(lastYearFurlough.subtract(restLastYearFurlough).subtract(usingLastYearFurlough));
			newRestVacationBean.setLastYearRestVacation(restLastYearFurlough.subtract(usingLastYearFurlough));
			newRestVacationBean.setLastYearTotalVacation(lastYearFurlough);
			newRestVacationBean.setRealLastYearRestVacation(restLastYearFurlough);
		}
		return newRestVacationBean;
	}
	
}
